<?php
	/* Página do fórum em si */

	session_start();

	include("/var/www/html/vivencias/conexaoBD.php");

	$query0 = "SELECT titulo FROM foruns WHERE idForum='".$_GET['idForum']."'";
	$resultado0 = mysql_query($query0,$conexao);
	$objeto0 = mysql_fetch_object($resultado0);

	$query = "SELECT tituloTopico FROM forumTopicos WHERE idForumTopicos='".$_GET['idForumTopicos']."'";
	$resultado = mysql_query($query,$conexao);
	$objeto = mysql_fetch_object($resultado);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Experi&ecirc;ncias do Processo de Adoecimento</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="vivencias.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="f6fafe">
<div align="center">
  <table width="550" border="0">
    <tr>
      <td align="center" valign="top"> <table width="95%" border="0" cellpadding="5" cellspacing="1">
          <tr>
            <td align="center" valign="middle" bgcolor="d5e1ee">
              <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
		<?php
			if($_GET['idTipoForum'] == 0){//principal
				echo '<tr align="center" bgcolor="6f0a36" class="texttab">';
			}else if($_GET['idTipoForum'] == 1){//prof,prof
				echo '<tr align="center" bgcolor="9d1733" class="texttab">';
			}else if($_GET['idTipoForum'] == 2){//prof,paciente
				echo '<tr align="center" bgcolor="d41a27" class="texttab">';
			}else if($_GET['idTipoForum'] == 3){//prof,aluno,paciente
				echo '<tr align="center" bgcolor="e14e1a" class="texttab">';
			}else if($_GET['idTipoForum'] == 4){//aluno,aluno
				echo '<tr align="center" bgcolor="d36e3c" class="texttab">';
			}else if($_GET['idTipoForum'] == 5){//paciente,paciente
				echo '<tr align="center" bgcolor="eab22a" class="texttab">';
			}
		?>
                  <td colspan="2" align="left" valign="top">&nbsp;</td>
                </tr>
                <tr align="center" bgcolor="83b3e3" class="texttab">
                  <td width="93%" align="left" valign="top"> <span class="ativomenor">F&oacute;rum
                    <?php echo $objeto0->titulo;?> - <?php echo $objeto->tituloTopico;?></span></td>
                  <td width="7%" align="right" valign="top">
                    <div align="right"><a href="javascript:void(null);" onclick="window.close();"><img src="imagens/x.jpg" width="21" height="21" border="0"></a></div></td>
                </tr>
                <tr align="center" bgcolor="d5e1ee" class="texttab">
                  <td colspan="2" align="left" valign="top" class="texto2"><strong>Enviar
                    coment&aacute;rio</strong></td>
                </tr>
		<form action="insereMensagemForum.php" method="post">
                <tr align="center" bgcolor="d5e1ee" class="texttab">
                  <td colspan="2" align="left" valign="top" class="texto2"> <textarea name="mensagem" cols="45" rows="5"></textarea>
		  <input type="hidden" name="idForumTopicos" value="<?php echo $_GET['idForumTopicos'];?>">
		  <input type="hidden" name="idForum" value="<?php echo $_GET['idForum'];?>">
		  <input type="hidden" name="idTipoForum" value="<?php echo $_GET['idTipoForum'];?>">
                  </td>
                </tr>
                <tr align="center" bgcolor="d5e1ee" class="texttab">
                  <td colspan="2" align="left" valign="top" class="texto2"> <input type="submit" name="Submit" value="Enviar">
                  </td>
                </tr>
	       </form>
              </table>
            </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
        <!--  <tr>
            <td><div align="center">
                <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                  <tr align="center" bgcolor="#38708F" class="texttab">
                    <td align="left" valign="top" bgcolor="83b3e3"> <span class="titsub">Usu&aacute;rios
                      OnLine: F&aacute;bio Maia / Paula Ramos / Patr&iacute;cia
                      Zudio</span></td>
                  </tr>
                </table>
              </div></td>
          </tr>-->

	 <form method="post" action="forumMensagens.php?idForumTopicos=<?php echo $_GET['idForumTopicos'];?>&idTipoForum=<?php echo $_GET['idTipoForum'];?>&idForum=<?php echo $_GET['idForum'];?>">
	 <tr>
            <td><div align="center">
                <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                  <tr align="center" bgcolor="#38708F" class="texttab">
                    <td align="left" valign="top" bgcolor="83b3e3">
			<span class="titsub">
				<input type="submit" value="Atualizar Agora">
			</span></td>
                  </tr>
                </table>
              </div></td>
          </tr>
	  </form>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><div align="center">
                <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                  <tr align="center" bgcolor="#38708F" class="texttab">
                    <td align="left" valign="top" bgcolor="83b3e3"> <span class="titsub"><strong>Coment&aacute;rios</strong></span>
                    </td>
                  </tr>
                </table>
              </div></td>
          </tr>
	<?php
		$query1 = "SELECT forumMensagens.mensagem,usuarios.nome,forumMensagens.data FROM forumMensagens,usuarios WHERE forumMensagens.idForumTopicos='".$_GET['idForumTopicos']."' AND forumMensagens.idRemetente=usuarios.idUsuario ORDER BY data DESC";
		$resultado1 = mysql_query($query1,$conexao);
		while($objeto1 = mysql_fetch_object($resultado1)){
	?>
          <tr>
            <td><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                <tr align="center" bgcolor="#38708F" class="texttab">
                  <td align="left" valign="top" bgcolor="d5e1ee" class="texto">
		    <?php echo nl2br($objeto1->mensagem);?>
		  </td>
                </tr>
                <tr align="center" bgcolor="#38708F" class="texttab">
                  <td align="left" valign="top" bgcolor="abc9e6">
                    <div align="left" class="texto2"><?php echo $objeto1->nome;?>&nbsp;&nbsp;<?php echo $objeto1->data;?></div></td>
                </tr>
              </table>

            </td>
          </tr>
	<?php } ?>

          <tr>
            <td>&nbsp; </td>
          </tr>
        </table>
        <p align="center">&nbsp;</p>
        <p><br>
        </p>
        </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  </div>
</body>
</html>
